class Solution {
public:
    vector<int> runningSum(vector<int>& nums) {
        vector<int> v;
        int sum = 0;
        for (int i = 0; i < nums.size(); i++)
        {
            sum = sum + nums[i];
            v.push_back(sum);
        }
        return v;
    }
};
class Solution {
public:
    int searchInsert(vector<int>& nums, int target) {
        int begin = 0;
        int end = nums.size() - 1;
        int size1 = (begin + end) / 2;
        if (nums[begin] > target)
        {
            return 0;
        }
        if (nums[end] < target)
        {
            return nums.size();
        }
        while ((end - begin) / 2)
        {
            if (nums[size1] < target)
            {
                begin = size1;
                size1 = begin + (end - begin) / 2;
            }
            else if (nums[size1] > target)
            {
                end = size1;
                size1 = begin + (end - begin) / 2;
            }
            else
            {
                break;
            }
        }
        if (nums[size1] == target)
        {
            return size1;
        }
        return size1 + 1;
    }
};
class Solution {
public:
    int Size(ListNode* head)
    {
        int a = 0;
        while (head)
        {
            a++;
            head = head->next;
        }
        return a - 1;
    }
    int getDecimalValue(ListNode* head) {
        int size = Size(head);
        int sum = 0;
        ListNode* cur = head;
        while (cur)
        {
            sum += pow(2, size) * (cur->val);
            size--;
            cur = cur->next;
        }
        return sum;

    }
};